package com.desmart.renjiao.orgainzation;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.desmart.renjiao.R;
import com.desmart.renjiao.bean.Company;
import com.desmart.renjiao.contants.Constants;
import com.lemon.library.common.ARoutePath;
import com.lemon.library.common.CommonActivity;
import java.util.List;

@Route(path = ARoutePath.addresslist.DepartmentListActivity)
public class DepartmentListActivity extends CommonActivity{

    private List<Company.Department> mlist;
    private RecyclerView recyclerview;

    @Override
    public int bindLayout() {
        return R.layout.activity_department_list;
    }

    @Override
    public void initView(Activity activity) {
        String title = getIntent().getStringExtra(Constants.Department.Key_DepartMentTitle);
        mlist = (List<Company.Department>) getIntent().getSerializableExtra(Constants.Department.Key_DepartMent);
        setTitleText(title);
        initSearchView(activity);
        recyclerview = activity.findViewById(R.id.recyclerview);
        DepartmentItemAdapter adapter = new DepartmentItemAdapter(mlist);
        recyclerview.setLayoutManager(new LinearLayoutManager(this));
        recyclerview.setAdapter(adapter);
    }

    private void initSearchView(Activity activity) {
        ImageView ivRight = activity.findViewById(R.id.common_iv_right);
        ivRight.setVisibility(View.VISIBLE);
        ivRight.setOnClickListener(this);
    }

    @Override
    public void initData(Context context) {

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (v.getId() == R.id.common_iv_right){
            ARouter.getInstance().build(ARoutePath.addresslist.MemberSearchActivity).navigation();
        }

    }
}
